﻿using System.Collections.Specialized;
using System.IO;

namespace MyWcfRestLib.Files
{
    class OnePathOpParams : FileOpParams
    {
        public const string PathKey = "path";

        public OnePathOpParams(string basePath, NameValueCollection requestQueryParams, Stream requestBody = null)
            : base(basePath, requestQueryParams, requestBody)
        {
            // Fix path string
            WorkingPath = (string)QueryParams[PathKey];
            if (null != WorkingPath)
            {
                WorkingPath = WorkingPath.Trim(InvalidFileNameChars);
            }
        }

        public string WorkingPath { get; private set; }

        public override bool IsValid
        {
            get { return UtilityFunctions.IsValidPathName(WorkingPath); }
        }
    }
}
